package sg.techstudio.suntec.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import sg.techstudio.suntec.dao.RadiusDao;

@Controller
public class CmsHomeController extends BaseController {

	@Override
	protected String getModuleFolder() {
		return "cms/home/";
	}
	
	@Autowired
	private RadiusDao radiusDao;

	@RequestMapping(value = "cms/dashboard/login" + SPRING_EXT)
	public String login(Model model) {
		
		
		return goToPageJsp("login");
	}
	
	@RequestMapping(value = "cms/dashboard/main" + SPRING_EXT)
	@PreAuthorize("hasRole('ROLE_CMS')")
	public String main(Model model) {
		
		model.addAttribute("drList", radiusDao.getRadacctGroupByDay());
		return goToPageJsp("main");
	}
}
